<template>
	<view class="feedback">
		<view>
			<textarea class="feedback-textarea" v-model="feedbackValue" placeholder="请说明问题描述，我们将为您不断改进~" />
			<view class="feedback-textarea-length">
				{{feedbackValue.length||0}}/200
			</view>
		</view>

		<view class="feedback-title">
			上传截屏/录屏/微信二维码（客服添加微信方便沟通）
		</view>

		<view class="feedback-upload-content">
			<img :src="uploadUrl" class="feedback-upload-item" alt="" v-if="uploadUrl" @click="uploadImg" />
			<view v-else class="feedback-upload-item" @click="uploadImg">
				<img src="https://www.jk334.cn/img/upload-icon.png" alt="" class="feedback-upload-item-icon" />
			</view>
		</view>
		<view class="feedback-sign">
			提交
		</view>
	</view>
</template>

<!-- 意见反馈 -->
<script>
	export default {
		data() {
			return {
				feedbackValue: '',
				uploadUrl: '',
			}
		},
		methods: {
			uploadImg() {
				uni.chooseImage({
					count: 1, //默认9
					sizeType: ['original'], //可以指定是原图还是压缩图，默认二者都有
					sourceType: ['album', 'camera'], //从相册选择
					success: (res) => {
						const imgUrl = res.tempFilePaths || []
						if (imgUrl[0]) {
							this.uploadUrl = imgUrl[0] || ''
						}
						console.log(JSON.stringify(res.tempFilePaths));
					}
				});
			},

		}
	}
</script>

<style scoped lang="scss">
	.feedback {
		border-top: #F6F6F6 solid 2rpx;
		background: #FFF;
		font-family: PingFang SC, PingFang SC;

		.feedback-textarea {
			margin: 66rpx 48rpx 0 48rpx;
			font-size: 26rpx;
			height: 286rpx;
		}

		.feedback-textarea-length {
			margin: 0 48rpx;
			text-align: end;
			font-size: 24rpx;
			font-weight: 400;
			color: #D2D2D2;
		}

		.feedback-textarea::placeholder {
			font-family: PingFang SC, PingFang SC;
			font-weight: 400;
			color: #999999;
		}

		.feedback-title {
			margin: 0rpx 48rpx;
			font-size: 20rpx;
			font-weight: 400;
			color: #999999;
			margin-bottom: 26rpx;
		}


		.feedback-upload-content {
			margin: 0rpx 48rpx;

			.feedback-upload-item {
				width: 222rpx;
				height: 222rpx;
				background: #F4F4F4;
				border-radius: 8rpx;
				display: flex;
				justify-content: center;
				align-items: center;

				.feedback-upload-item-icon {
					width: 60rpx;
					height: 60rpx;
				}
			}
		}

		.feedback-sign {
			position: fixed;
			bottom: 40rpx;
			left: 50%;
			transform: translate(-50%, -20%);
			width: 520rpx;
			height: 80rpx;
			text-align: center;
			line-height: 80rpx;
			background: #FFCD2C;
			border-radius: 80rpx;
			font-size: 28rpx;
			font-weight: bold;
			color: #393319;
		}
	}
</style>